package a20.com.yuejian_20.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

import a20.com.yuejian_20.R;
import a20.com.yuejian_20.activity.ClubdetailActivity;
import a20.com.yuejian_20.adapter.ClubListAdapter;
import a20.com.yuejian_20.bean.ClubPicture;
import a20.com.yuejian_20.model.ClubModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by ASURA on 2017/9/26.
 */

public class ClubFragment extends Fragment {
    View view;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.frag_club,container,false);//整个布局

        ClubModel clubModel = new ClubModel();//初始化model 不然什么都装不了

        Call<List<ClubPicture>> call = clubModel.getPicture(); //返回ID  图片  名字



        call.enqueue(new Callback<List<ClubPicture>>() {
            @Override
            public void onResponse(Call<List<ClubPicture>> call, Response<List<ClubPicture>> response) {
                List  list = response.body();//存数据

                ListView listView =(ListView)view.findViewById(R.id.clublist);//根据id

//        ArrayList<String> aaa = new ArrayList<String>();
//        aaa.add("ssss");
//        aaa.add("ssss");
//        aaa.add("ssss");
//        aaa.add("ssss");
                ClubListAdapter zzz = new ClubListAdapter(getContext(),R.layout.frag_club,list);
                listView.setAdapter(zzz);

            }

            @Override
            public void onFailure(Call<List<ClubPicture>> call, Throwable t) {

            }
        });


        return view;
    }

//    private void getData() {
//
//     }






//
//        Button btn = (Button)findViewById(R.id.imageView);
//        btn.setOnClickListener(new onClickListener){
//
//         public void onClick(View v){
//                Intent intent = new Intent(ClubFragment.this, ClubdetailActivity.class);
//                startActivity(intent);
//            }
//
//
//        }





}
